﻿





    //***************************************************************
    //定义页面对象
    (function initi() {
        function Page() {
            this.baseUrl = "/OriginsMaterial/";
            this.action = "";
        }
        function Entity() {
            this.MaterialName = "";
            this.MaterialId = "";
            this.TitleStyle = "";
            this.CoverImg = "";
            this.IsAuthNavShow = "";
            this.ChangeColor = "2";
        }
        function ModuleEntity() {
            this.ModuleId = "";
            this.TitleStyle = "";
        }
        window.entity = new Entity();
        window.page = new Page();
        window.moduleEntity = new ModuleEntity();
    })(window);

//***************************************************************


/****************************************************绑定编辑start***********************************************/

$(document).ready(function () {
    GetMaterialModelByMaterilId($("#materialId").val());
});
var ue = UE.getEditor('editor');

function GetMaterialModelByMaterilId(materialId) {

    $.ajax({
        type: "POST",
        dataType: 'json',
        url: page.baseUrl + "GetMaterialModelByMaterialId?materialId=" + materialId,
        cache: false,
        success: function (data) {
            BindMaterialModel(data);
            GetModuleListByMaterialId($("#materialId").val());
        }
    });

}

function GetModuleListByMaterialId(materialId) {
        
    $.ajax({
        type: "POST",
        dataType: 'json',
        url: page.baseUrl + "GetModuleListByMaterialId?materialId=" + materialId,
        cache: false,
        success: function (data) {
            BindModuleList(data);
        }
    });

}

function BindMaterialModel(materialModel) {

        


    var EID = $("#EID").val();
    $.MGJ.DiamondEdition.Ajax_GetBatchListByEID(EID);


    entity = materialModel;
    moduleEntity.TitleStyle = materialModel.TitleStyle;

    if (materialModel.CoverImg != null) {
        $("#CoverBG").attr("src", materialModel.CoverImg);
        $("#CoverPic").val(materialModel.CoverImg)
    }
}





function BindModuleList(moduleList) {

    if (moduleList.length == 0) {
        var html = $.HtmlHelper.GetSelectExampleHtml();
        $("body").append(html);
    }
    appendList(moduleList);
}








function ModuleEdit(ob) {

    var x = $(ob).offset().top;
    var x0 = $(".site-navbar.navbar.navbar-default.navbar-fixed-top.navbar-inverse ").height();
    var x1 = $("#admui-siteConTabs").height();

    $(".rightc").css({ 'top': x-x0-x1 });
    var type = $(ob).attr("data-type");
    var moduleId = $(ob).attr("data-id");
    setModuleClass(moduleId);
    hideAll();
    $(".rightc").css("display", "inline-block");
    if (type == "text") {
        $("#fMaterialName").val(entity.MaterialName);
        $("#ProductBatch").val(entity.ProductBatch);
        $("#TitleStyle1").val(entity.TitleStyle);
        $("input[name='IsAuthNavShow'][value=" + entity.IsAuthNavShow + "]").attr("checked", true);
        $("#textEditWrap").show();
    }
    if (type == 0) {
            
        $("#twEditWrap").show();
        SetModule(moduleId);
    }
    else if (type == 1) {
        $("#wzdhEditWrap").show();
        SetModule(moduleId);
    }
    else if (type == 2) {
        $("#cpxxEditWrap").show();
        SetModule(moduleId);
    }
    else if (type == 3) {
        $("#chxxEditWrap").show();
        SetModule(moduleId);
    }
    //else if (type == 4) {
    //    $("#ppwhEditWrap").show();
    //    SetModule(moduleId);
    //}
}

$("#MaterialNameWrap").on("click",function () {
    ModuleEdit(this);
});

function SetModule(moduleId) {
  
    $.ajax({
        type: "POST",
        dataType: 'json',
        url: page.baseUrl + "GetModuelById?id=" + moduleId,
        cache: false,
        success: function (data) {
            if (typeof data != 'object') {
                var entity = $.parseJSON(data)
            } else {
                var entity = data;
            }
         
            bindingModule(entity);
        }
    });
}


function bindingModule(entity) {


    
    moduleEntity = entity;
    //图文
    if (entity.ModuleType == 0) {

        $("#twForm #Title").val(entity.Title);
        $("#twForm input[name='IsHide'][value=" + entity.IsHide + "]").attr("checked", true);
        $("#twForm input[name='IsHideTitle'][value=" + entity.IsHideTitle + "]").attr("checked", true);
        ue.setContent(entity.ModuleContent);

    }
    //导航
    if (entity.ModuleType == 1) {
   
        $("#wzdhTitle").val(entity.Title)
        $("input[name='IsHideTitle2'][value=" + entity.IsHideTitle + "]").attr("checked", true);
        $("input[name='NavStyle'][value=" + entity.NavStyle + "]").attr("checked", true);


        setNavList(entity.ModuleId,"default")
    }
    if (entity.ModuleType == 2) {
             
     

        entity.ModuleContent = $.HtmlHelper.GetProductTableHtml();

        $("#cpxxform input[name=Title]").val(entity.Title);
        $("#cpxxform input[name='IsHide'][value=" + entity.IsHide + "]").attr("checked", true);
        $("#cpxxform input[name='IsHideTitle'][value=" + entity.IsHideTitle + "]").attr("checked", true);
        $("#cpxxInfo").html(entity.ModuleContent);

    }
    if (entity.ModuleType == 3) {



        $("#chxxform input[name=Title]").val(entity.Title);
        $("#chxxform input[name='IsHide'][value=" + entity.IsHide + "]").attr("checked", true);
        $("#chxxform input[name='IsHideTitle'][value=" + entity.IsHideTitle + "]").attr("checked", true);
        $("#chxxInfo").html(entity.ModuleContent);

    }

}

/****************************************************图文导航素材标题保存start***********************************************/

$("#twSave").click(function () {
    SavetwModule()
});

$("#navSave").click(function () {
    SaveNavModule();
    //document.getElementById('playBox').contentWindow.location.reload(true);
});

$("#cpxxSave").click(function () {
    var obj = $("#cpxxform").serializeObject();
    cpxxModuleSave(obj);

});

$("#chxxSave").click(function () {
    var obj = $("#chxxform").serializeObject();
    cpxxModuleSave(obj);

});




//保存text修改信息（此处仅有素材标题是text信息修改）
$("#textSave").click(function () {
    $(document.body).append('<div id="lgh_loading_layer"><div class="lgh_loadingIcon lgh_loadingIcon_1" id="lgh_loading"></div></div>');

    entity.MaterialName = $("#fMaterialName").val();
    entity.ProductBatch = $("#SBatchList").val();
    entity.TitleStyle = $("#TitleStyle1").val();
    entity.CoverImg = $("#CoverImg").val();
    entity.IsAuthNavShow = $('input:radio[name="IsAuthNavShow"]:checked').val();

    $.ajax({
        type: "post",
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        url: page.baseUrl + "MaterialSave",
        data: "{\"model\":" + JSON.stringify(entity) + "}",
        cache: false,
        success: function (msg) {
            $.L.msgSuccess("操作成功")
            $("#MaterialName").text(entity.MaterialName);
            hideAll();
            $("#lgh_loading_layer").remove()
        },
        error: function (jqXHR, textStatus, errorThrown) {
            $.L.msgError("请求异常" + jqXHR.statusText)
            $("#lgh_loading_layer").remove()
        }
    });
});


/****************************************************模块添加start***********************************************/

///添加图文模块
$("#tw").click(function () {
    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 0;
        this.Title = "图文";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        this.ModuleContent = " ";
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();
    ModuleSave(moduleEntity);
});

///添加网址导航模块
$("#wzdh").click(function () {
      
    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 1;
        this.Title = "网址导航";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        this.ModuleContent = "";
        this.NavStyle = 3;
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();
        
    ModuleSave(moduleEntity);

});

///添加产品信息模块【此模块为固定模块】
$("#cpxx").click(function () {
        
    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 2;
        this.Title = "产品信息";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        this.ModuleContent = $.HtmlHelper.GetProductTableHtml();
        this.NavStyle = 3;
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();

    ModuleSave(moduleEntity);

});

//添加窜货信息模块
$("#chxx").click(function () {

    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 3;
        this.Title = "窜货信息";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        //this.ModuleContent = $.HtmlHelper.GetProductTableHtml();

        this.ModuleContent = "      ";

        this.NavStyle = 3;
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();

    ModuleSave(moduleEntity);

});











///添加企业简历模块
$("#qyjl").click(function () {

    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 3;
        this.Title = "企业简历";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        this.ModuleContent = "";
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();
    ModuleSave(moduleEntity);
});

///添加品牌文化模块
$("#ppwh").click(function () {

    var moduleModel = function () {
        this.ModuleId = 0;
        this.MaterialId = entity.MaterialId;
        this.ModuleType = 4;
        this.Title = "品牌文化";
        this.IsHideTitle = 0;
        this.IsHide = 0;
        this.ModuleContent = "";
        this.Sort = getSortValue();
    }
    var moduleEntity = new moduleModel();
    ModuleSave(moduleEntity);
});

$(document).ready(function () {

    getSortValue();


});

function getSortValue() {
    var moduleList = $(".boxWrap");
    return moduleList.length+1;
}





function ModuleSave(moduleEntity) {

    $(document.body).append('<div id="lgh_loading_layer"><div class="lgh_loadingIcon lgh_loadingIcon_1" id="lgh_loading"></div></div>');
    $.ajax({
        type: "post",
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        url: "/OriginsMaterial/" + "ModuleSave",
        data: "{\"model\":" + JSON.stringify(moduleEntity) + "}",
        cache: false,
        success: function (data) {
            moduleEntity.ModuleId = data;
            window.moduleEntity.ModuleId = data;
            append(moduleEntity);
            $("#lgh_loading_layer").remove();
        },
        error: function (jqXHR, textStatus, errorThrown) {
            $.L.msgError("请求异常" + jqXHR.statusText)
            $("#lgh_loading_layer").remove()
        }
    });

}









//插入模块信息到列表
function append(moduleEntity) {
    var html = createModuleHtml(moduleEntity);
    $("#sortModuleList").append(html);
}


function appendList(moduleList) {
    var html = " ";
    for (var i = 0; i < moduleList.length; i++) {
        var moduleEntity = moduleList[i];
        moduleEntity.TitileStyle = entity.TitleStyle;
        html += createModuleHtml(moduleEntity);
    }
    $("#sortModuleList").append(html);
}


function rebackNavHtml(html, type) {
    if (type == 0) {
        $("#navList tbody").append(html);
    } else if (type == 1) {
        $("#authnavList tbody ").append(html);
    }

}

/****************************************************模块删除start***********************************************/

function del(id) {
    $(document.body).append('<div id="lgh_loading_layer"><div class="lgh_loadingIcon lgh_loadingIcon_1" id="lgh_loading"></div></div>');

    $.ajax({
        type: "post",
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        url: "/OriginsMaterial/" + "ModuleDelete",
        data: "{\"id\":" + id + "}",
        cache: false,
        success: function (data) {
            $("#" + id).remove();
            $("#lgh_loading_layer").remove()
        },
        error: function (jqXHR, textStatus, errorThrown) {

            $.L.msgError("请求异常" + jqXHR.statusText)
            $("#lgh_loading_layer").remove()
        }
    });
}


function DelClick(_this, e) {
    $.L.msgConfirm("确认删除该模块?", function () {
        var id = $(_this).children(".delete").attr("data-id");
        del(id);
    })
    e.stopPropagation();
}




function navdel(ob) {
    $(document.body).append('<div id="lgh_loading_layer"><div class="lgh_loadingIcon lgh_loadingIcon_1" id="lgh_loading"></div></div>');
    var id = $(ob).attr("data-id");

    $.ajax({
        type: "post",
        dataType: 'json',
        contentType: "application/json; charset=utf-8",
        url: "/OriginsMaterial/" + "NavDelete",
        data: "{\"id\":" + id + "}",
        cache: false,
        success: function (data) {
            $(ob).parent().parent().parent().remove();
            $("#lgh_loading_layer").remove()
        },
        error: function (jqXHR, textStatus, errorThrown) {
            //$.L.msgError(jqXHR.responseText)
            $.L.msgError("请求异常" + jqXHR.statusText)
            $("#lgh_loading_layer").remove()
        }
    });
}

function setAuthNavList(authList) {

    appendNavList(authList, "auth");
}

///生成导航列表【导航编辑列列表】
//type  default  默认导航  auth 验证模块
function setNavList(moduleId, type) {
    $.ajax({
        type: "POST",
        dataType: 'json',
        url: "/OriginsMaterial/" + "GetNavListByModuleId?id=" + moduleId,
        cache: false,
        success: function (data) {
            if (typeof data != 'object') {
                var entity = $.parseJSON(data)
            } else {
                var entity = data;
            }
            appendNavList(entity, type);
        }
    });
}


function appendNavList(navList,type) {

    var html = '<table class="tbIos">';
    html += '<tbody>';
    for (var i = 0; i < navList.length; i++) {

        var navEntity = navList[i];
        html += createNavhtml(navEntity);
    }
    html+="</tbody>"
    html += "</table>";

    if (type == "default") {
        $("#navList").html(html);
    }
    if (type == "auth") {
        $("#authnavList").html(html);
    }

}

/****************************************************素材预览start***********************************************/

function Preview() {

    var obj = {
        materialId: $("#materialId").val(),
        batchId: $("#batchId").val()
    }

    $.MGJ.Common._PrewView(obj.materialId, obj.batchId);
}



    
/****************************************************默认模块start***********************************************/


function BindModuleList_main_hide() {

    $("#BindModuleListMain").hide();
    modal_select_plugins_main_hide();
}

var BindModuleListNum = undefined;
function BindModuleListBtn(_this) {
    BindModuleListNum = $(_this).attr("BindModuleListNum")
}

function BindModuleListResults() {
    if (BindModuleListNum != undefined) {
        $("#BindModuleList").val(BindModuleListNum)
        modal_select_plugins_main_hide()
    } else {
        $.L.msgError("尚未选择")
    }
}

function GoFirstStep() {
    $(".FirstStep").show()
    $(".SecondStep").hide()
    $(".ThirdStep").hide()
    $(".FourthStep").hide()
}

function GoSecondStep() {
    $(".FirstStep").hide()
    $(".SecondStep").show()
    $(".ThirdStep").hide()
    $(".FourthStep").hide()
}

function GoThirdStep() {
    $(".FirstStep").hide()
    $(".SecondStep").hide()
    $(".ThirdStep").show()
    $(".FourthStep").hide()
}

function GoFourthStep() {
    $(".FirstStep").hide()
    $(".SecondStep").hide()
    $(".ThirdStep").hide()
    $(".FourthStep").show()
}

var clickTime = 0;
$(document).on("click", ".BindModuleListSelect", function () {

    GoSecondStep()

    var index = $(".BindModuleListSelect").index($(this)) + 1
    if (index == 6) {
        index = 0;
    }
    if (clickTime > 0) {
        return;
    }

    clickTime++;
    $(this).attr("disabled", "disabled");
    if (index != 0) {

        var fromMaterialId = $(this).attr("data-materialId");

        SetExample(fromMaterialId, $("#materialId").val());
    }



})






function SetExample(fromMaterialId, toMaterialId) {

    $.ajax({
        type: "POST",
        dataType: 'json',
        url: page.baseUrl + "CopyMaterial?fromMaterialId=" + fromMaterialId + "&toMaterialId=" + toMaterialId,
        cache: false,
        success: function (data) {
            if (data > 0) {
                GetModuleListByMaterialId($("#materialId").val());
            }
        }
    });
}







/****************************************************模块拖拽排序start***********************************************/



var currentDrag = "";
var currentDragWrap = "";
$(function () {
    $("#sortModuleList").sortable({
        start: function (e) {
            hideAll();
            var s = $(e.toElement)[0];
            var a = $(s).parent()[0];

            currentDrag = $(s);
            currentDrag.addClass("dragCurrent");

            currentDragWrap = $(a);
            currentDragWrap.addClass("dragCurrent");

        },
        stop: function (e) {

            currentDrag.removeClass("dragCurrent");
            currentDragWrap.removeClass("dragCurrent");

            sortModule();
        },

        delay: 300

    });
    $("#sortModuleList").disableSelection();
});

function getSort() {
        
    var sortList = $("#sortModuleList li");
    var list_ = [];
    for (var i = 0; i < sortList.length; i++) {
        list_[i] = $(sortList[i]).attr("data-id")
    }
    return list_;
}

function sortModule() {
    var json = getSort();
    $.ajax({
        type: "POST",
        dataType: 'json',
        url: "/OriginsMaterial/SortModule",
        data: { json: json },
        traditional: true,
        cache: false,
        success: function (data) {
            data =  $.parseJSON(data)
        },
        error: function (jqXHR, textStatus, errorThrown) {
            //console.log(jqXHR.responseText);
        }
    });
}

/****************************************************导航样式选择start***********************************************/

function onStyleSelect(obj) {

    var index = obj.text;
    var inputName = obj.name;


}
function rebackIndex(inputName, index) {

    $("#inputName").val(index).text(index);

    ReloadTitleStyle(index);
}

function ReloadTitleStyle(titleStyle) {

    $(".titlemodle").each(function () {
        var FindHtml = $(this).find(".titlemodle-find").context.innerText;
        $(this).after(TitleModule[titleStyle][0] + FindHtml + TitleModule[titleStyle][1])
        $(this).remove();
    })
}

/****************************************************上传模块start***********************************************/



function uploadEXT(id,url) {
    if (id == "CoverPic") {
        $("#CoverBG").attr("src", url);
    }
}


/****************************************************其他start***********************************************/

$("#me-close").click(function () {
    hideAll();
});

function setModuleClass(moduleId) {
    $(".current").each(function () {
        $(this).removeClass("current");
    })
    $("#" + moduleId).addClass("current");
}




/****************************************************其他Z start***********************************************/
//样式
$("#bgbody").css("min-height", $(".main-menu").height() - 106)
$(".fixed_right_icon").on("click", function () {
    $("#fixed_right").children().eq($(".fixed_right_icon").index($(this))).hide().siblings().show()
})
//蒙层手机样式
$(document).on("change", "#phone-model", function () {
    if ($(this).val() === "iphone7") {
        $(".iphone").css({ "width": "375px", "background-size": "100% 64px" })
        $(".playBox").css("margin-top", "-36px")
    } else if ($(this).val() === "iphone7plus") {
        $(".iphone").css({ "width": "414px", "background-size": "100% 70px" })
        $(".playBox").css("margin-top","-30px")
    }
})
//配色蒙层
$(".choose_tpl_color").click(function (e) {
    $("#modal_select_plugins_main").show()
    if ($(".modal_select_plugins_close").length === 0) {
        $(".modal_select_plugins_box").prepend('<a href="javascript:;" class="modal_select_plugins_close" onclick="modal_select_plugins_main_hide()"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span @*aria-hidden="true"*@>×</span></button></a>')
    }
    e.stopPropagation();
})
function modal_select_plugins_main_hide() {
    $(".modal_select_plugins_main").hide()
}

var PrepareColor,SelectColor
$(document).on("click", ".modal_select_plugins_select_button", function () {
    $(this).addClass('modal_active').siblings().removeClass('modal_active')
    PrepareColor = $(this).attr("color-id")

    $(".now_sel_image").attr("src", $(this).attr("color-image"))
})
$(document).on("click", ".modal_select", function () {
    modal_select_plugins_main_hide()
    SelectColor = PrepareColor;
    IfChangeColor(SelectColor-1)
    $(".first_color_block.left_triangle").css({ "background-color": $(".first_select_color").eq(SelectColor-1).css("background"), "border-right-color": $(".second_select_color").eq(SelectColor-1).css("background") })
    $(".change-color-find").each(function(){
        if ($(this).attr("change-color") == 0) {
            $(this).css("border-color", ChangeColor)
        }else if ($(this).attr("change-color") == 1) {
            $(this).css("background-color", ChangeColor)
        } else if ($(this).attr("change-color") == 2) {
            $(this).css("border-left-color",ChangeColor)
        } else if ($(this).attr("change-color") == 31) {
            $(this).css("border-color", ChangeColor)
        } else if ($(this).attr("change-color") == 32) {
            $(this).css("border-color", ChangeColor)
        } else if ($(this).attr("change-color") == 41) {
            $(this).css("background-color", ChangeColor)
        } else if ($(this).attr("change-color") == 42) {
            $(this).css("background-color", ChangeColor)
        } else if ($(this).attr("change-color") == 43) {
            $(this).css("background-color",ChangeColor)
        } else if ($(this).attr("change-color") == 44) {
            $(this).css("color",ChangeColor)
        } else if ($(this).attr("change-color") == 5) {
            $(this).css("border-color",ChangeColor)
        } else if ($(this).attr("change-color") == 61) {
            $(this).css("color",ChangeColor)
        } else if ($(this).attr("change-color") == 62) {
            $(this).css("color",ChangeColor)
        } else if ($(this).attr("change-color") == 7) {
            $(this).css("border-top", "2px solid" + ChangeColor)
        } else if ($(this).attr("change-color") == 81) {
            $(this).css({"color":ChangeColor,"border-bottom":"2px solid"+ChangeColor,"border-top":"2px solid"+ChangeColor,"border-right-color":ChangeColor,"border-left-color":ChangeColor})
        } else if ($(this).attr("change-color") == 82) {
            $(this).css("border-top","0.6em solid"+ChangeColor)
        }
    })


    //预留代码块

})






$(function () {

    $('.picker').mouseenter(function () {
        $(this).css('background-image', 'url("/Content/webImgs/upLogo/cp_img_tj_a.png")');
    }).mouseleave(function () {
        $(this).css('background-image', 'url("/Content/webImgs/upLogo/cp_img_tj.png")');
    })


    var uploader1 = WebUploader.create({
        // swf文件路径
        //swf: BASE_URL + '/js/Uploader.swf',
        // 文件接收服务端。
        server: 'OriginsMaterial/Upload',
        // 选择文件的按钮。可选。 内部根据当前运行是创建，可能是input元素，也可能是flash.
        pick: {
            id: '#picker1',
            multiple: false
        },
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/jpg,image/jpeg,image/png'
        },
        // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
        resize: false
    });



    function LoadItem(item, con, selector) {
        // 当有文件被添加进队列的时候
        item.on('fileQueued', function (file) {
            var $li = $(
       '<div  id="' + file.id + '" class="img-thumbnail">' +
       '<img alt="null"/>' +
       '</div>'
   ),
         $img = $li.find('img');
            $(selector).before($li);
            item.makeThumb(file, function (error, src) {
                if (error) {
                    $img.replaceWith('<span>不能预览</span>');
                    return;
                }
                $img.attr('src', src);
            }, 60, 60);

            $(con + '> div.img-thumbnail').mouseenter(function () {
                var url = $(this).find('img').attr('src');
                $(this).attr('name', url).find('img').attr('src', '/Content/webImgs/upLogo/cp_img_sc.png').css({ 'width': '60px', 'height': '60px' });
            }).mouseleave(function () {
                var url = $(this).attr('name');
                $(this).find('img').attr('src', url);
            }).click(function () {
                $(this).remove();
                $(selector).show();
            });

            $(selector).hide();
            item.upload();
        });

        // 文件上传过程中创建进度条实时显示。
        item.on('uploadProgress', function (file, percentage) {
            var $li = $('#' + file.id),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if (!$percent.length) {
                $percent = $('<div class="progress progress-striped active" style="margin:0;height:8px">' +
                  '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                  '</div>' +
                '</div>').appendTo($li).find('.progress-bar');
            }

            //$li.find('p.state').text('上传中');
            $("#Tips").text("上传中");

            $percent.css('width', percentage * 100 + '%');
        });
        item.on('uploadSuccess', function (file, r) {
            //$('#' + file.id).find('p.state').text('已上传');
            var result = r._raw.split("。")[1];
            if (selector == "#picker1") {
                $("#CoverImg").val(result);
            }
            //$("#Tips").text("已上传")
        });

        item.on('uploadError', function (file) {
            //$('#' + file.id).find('p.state').text('上传出错');
            $("#Tips").text("上传出错");
        });

        item.on('uploadComplete', function (file) {
            $('#' + file.id).find('.progress').fadeOut();
        });
        $('#UpLoad').click(function () {
            item.upload();
        })
    }


    LoadItem(uploader1, ".list-con", "#picker1");


});

//添加loading
//defaultOptions.container.append('<div class="lgh_loadingIcon lgh_loadingIcon_' + type + '" id="lgh_loading"></div>');
//去除loading
//$.L.loadingIconClose();


